home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / io / sys / stat.h < prev   
C/C++ Source or Header  |  1992-11-10  |  5KB  |  157 lines

  1. /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /*
  20.  *    POSIX Standard: 5.6 File Characteristics    <sys/stat.h>
  21.  */
  22.  
  23. #ifndef    _SYS_STAT_H
  24.  
  25. #define    _SYS_STAT_H    1
  26. #include <features.h>
  27.  
  28. #include <gnu/types.h>        /* For __mode_t and __dev_t.  */
  29.  
  30. __BEGIN_DECLS
  31.  
  32. #include <statbuf.h>
  33.  
  34. #if defined(__USE_BSD) || defined(__USE_MISC)
  35. #define    S_IFMT        __S_IFMT
  36. #define    S_IFDIR        __S_IFDIR
  37. #define    S_IFCHR        __S_IFCHR
  38. #define    S_IFBLK        __S_IFBLK
  39. #define    S_IFREG        __S_IFREG
  40. #define    S_IFLNK        __S_IFLNK
  41. #define    S_IFSOCK    __S_IFSOCK
  42. #define    S_IFIFO        __S_IFIFO
  43. #endif
  44.  
  45. /* Test macros for file types.    */
  46.  
  47. #define    __S_ISTYPE(mode, mask)    (((mode) & __S_IFMT) == (mask))
  48.  
  49. #define    S_ISDIR(mode)    __S_ISTYPE((mode), __S_IFDIR)
  50. #define    S_ISCHR(mode)    __S_ISTYPE((mode), __S_IFCHR)
  51. #define    S_ISBLK(mode)    __S_ISTYPE((mode), __S_IFBLK)
  52. #define    S_ISREG(mode)    __S_ISTYPE((mode), __S_IFREG)
  53. #define    S_ISFIFO(mode)    __S_ISTYPE((mode), __S_IFIFO)
  54.  
  55. #ifdef    __USE_GNU
  56. #define    S_ISLNK(mode)    __S_ISTYPE((mode), __S_IFLNK)
  57. #define    S_ISSOCK(mode)    __S_ISTYPE((mode), __S_IFSOCK)
  58. #endif
  59.  
  60.  
  61. /* Protection bits.  */
  62.  
  63. #define    S_ISUID __S_ISUID    /* Set user ID on execution.  */
  64. #define    S_ISGID    __S_ISGID    /* Set group ID on execution.  */
  65.  
  66. #if defined(__USE_BSD) || defined(__USE_MISC)
  67. /* Save swapped text after use (sticky bit).  This is pretty well obsolete.  */
  68. #define    S_ISVTX    __S_ISVTX
  69. #endif
  70.  
  71. #define    S_IRUSR    __S_IREAD    /* Read by owner.  */
  72. #define    S_IWUSR    __S_IWRITE    /* Write by owner.  */
  73. #define    S_IXUSR    __S_IEXEC    /* Execute by owner.  */
  74. /* Read, write, and execute by owner.  */
  75. #define    S_IRWXU    (__S_IREAD|__S_IWRITE|__S_IEXEC)
  76.  
  77. #if    defined(__USE_MISC) && defined(__USE_BSD)
  78. #define    S_IREAD        S_IRUSR
  79. #define    S_IWRITE    S_IWUSR
  80. #define    S_IEXEC        S_IXUSR
  81. #endif
  82.  
  83. #define    S_IRGRP    (S_IRUSR >> 3)    /* Read by group.  */
  84. #define    S_IWGRP    (S_IWUSR >> 3)    /* Write by group.  */
  85. #define    S_IXGRP    (S_IXUSR >> 3)    /* Execute by group.  */
  86. /* Read, write, and execute by group.  */
  87. #define    S_IRWXG    (S_IRWXU >> 3)
  88.  
  89. #define    S_IROTH    (S_IRGRP >> 3)    /* Read by others.  */
  90. #define    S_IWOTH    (S_IWGRP >> 3)    /* Write by others.  */
  91. #define    S_IXOTH    (S_IXGRP >> 3)    /* Execute by others.  */
  92. /* Read, write, and execute by others.  */
  93. #define    S_IRWXO    (S_IRWXG >> 3)
  94.  
  95.  
  96. /* Get file attributes for FILE and put them in BUF.  */
  97. extern int __stat __P ((__const char *__file, struct stat *__buf));
  98. extern int stat __P ((__const char *__file, struct stat *__buf));
  99.  
  100. /* Get file attributes for the file, device, pipe, or socket
  101.    that file descriptor FD is open on and put them in BUF.  */
  102. extern int __fstat __P ((int __fd, struct stat *__buf));
  103. extern int fstat __P ((int __fd, struct stat *__buf));
  104.  
  105. /* Get file attributes about FILE and put them in BUF.
  106.    If FILE is a symbolic link, do not follow it.  */
  107. extern int __lstat __P ((__const char *__file, struct stat *__buf));
  108. #ifdef    __USE_BSD
  109. extern int lstat __P ((__const char *__file, struct stat *__buf));
  110. #endif
  111.  
  112. /* Set file access permissions for FILE to MODE.
  113.    This takes an `int' MODE argument because that
  114.    is what `mode_t's get widened to.  */
  115. extern int __chmod __P ((__const char *__file, __mode_t __mode));
  116. extern int chmod __P ((__const char *__file, __mode_t __mode));
  117.  
  118. /* Set file access permissions of the file FD is open on to MODE.  */
  119. extern int __fchmod __P ((int __fd, __mode_t __mode));
  120. #ifdef    __USE_BSD
  121. extern int fchmod __P ((int __fd, __mode_t __mode));
  122. #endif
  123.  
  124.  
  125. /* Set the file creation mask of the current process to MASK,
  126.    and return the old creation mask.  */
  127. extern __mode_t __umask __P ((__mode_t __mask));
  128. extern __mode_t umask __P ((__mode_t __mask));
  129.  
  130. #ifdef    __USE_GNU
  131. /* Get the current `umask' value without changing it.
  132.    This function is only available under the GNU Hurd.  */
  133. extern __mode_t getumask __P ((void));
  134. #endif
  135.  
  136. /* Create a new directory named PATH, with permission bits MODE.  */
  137. extern int __mkdir __P ((__const char *__path, __mode_t __mode));
  138. extern int mkdir __P ((__const char *__path, __mode_t __mode));
  139.  
  140. /* Create a device file named PATH, with permission and special bits MODE
  141.    and device number DEV (which can be constructed from major and minor
  142.    device numbers with the `makedev' macro above).  */
  143. extern int __mknod __P ((__const char *__path,
  144.              __mode_t __mode, __dev_t __dev));
  145. #if    defined(__USE_MISC) || defined(__USE_BSD)
  146. extern int mknod __P ((__const char *__path,
  147.                __mode_t __mode, __dev_t __dev));
  148. #endif
  149.  
  150.  
  151. /* Create a new FIFO named PATH, with permission bits MODE.  */
  152. extern int mkfifo __P ((__const char *__path, __mode_t __mode));
  153.  
  154. __END_DECLS
  155.  
  156. #endif /* sys/stat.h  */
  157.